package com.js.nickcar.base;

import com.js.nickcar.api.ErrorCode;
import com.js.nickcar.entity.remote.ApiResultBean;
import com.js.nickcar.exception.ApiException;

import rx.functions.Func1;


/**
 * Created by 李宗源 on 2017/4/25.
 */

public class HttpResultFunc<T> implements Func1<ApiResultBean<T>, T> {
    @Override
    public T call(ApiResultBean<T> resultBean) {
        if (resultBean.getErr_no() != ErrorCode.ERROR_200) {
            throw new ApiException(resultBean.getMsg());
        }
        return resultBean.getData();
    }
}
